refactor(core): expose core.locale as LocaleProxy#3820
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I marked this as P2, because it needs to be decided on prior to the next release. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3820 +/- ##
==========================================
- Coverage 98.90% 98.84% -0.07%
==========================================
Files 897 898 +1
Lines 3103 3113 +10
Branches 556 559 +3
==========================================
+ Hits 3069 3077 +8
- Misses 30 32 +2
Partials 4 4
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors locale handling so FakerCore exposes locale data as a LocaleProxy, and adds a raw escape hatch to access underlying LocaleDefinition data without proxy behavior.
Changes:
- Change
FakerCore.localeto be aLocaleProxyand wrap locales viacreateLocaleProxy()increateFakerCore(). - Add
raw(and an internal tag) toLocaleProxy, and allowcreateLocaleProxy()to accept an existingLocaleProxy. - Update modules/tests to use
definitions.rawwhere non-throwing access to locale definitions is needed.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/internal/locale-proxy.spec.ts | Adds a test for passing a LocaleProxy into createLocaleProxy(). |
| src/modules/person/index.ts | Switches last-name pattern lookup to use raw definitions. |
| src/modules/helpers/eval.ts | Updates fakeEval default entrypoints to use raw definitions. |
| src/internal/locale-proxy.ts | Extends LocaleProxy with raw + tag and updates proxy creation logic. |
| src/faker.ts | Removes stored definitions field; exposes definitions/rawDefinitions via getters. |
| src/core.ts | Makes FakerCore.locale a LocaleProxy and ensures core construction proxies locales. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Alternative to #3189 and #3819feat: de-proxy locale access #3189feat: introduce resolveLocaleData utility function #3819LocaleProxyinFakerCore.rawattribute to get access to the raw LocaleDefinitions (to avoid issues with locale data existence checks)